package com.fitness.fitness.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fitness.fitness.modal.coach.entity.CoachComment;
import com.fitness.fitness.modal.coach.param.CoachCommentQueryParams;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface CoachCommentMapper extends BaseMapper<CoachComment> {

    @Select("select * from t_coach_comment c where c.coach_id = #{queryParams.coachId} order by create_time desc")
    Page<CoachComment> getCoachCommentPage(Page<CoachComment> page, @Param("queryParams") CoachCommentQueryParams queryParams);

    @Select("<script>select * from t_coach_comment c"
            + " <where>"
            + "<if test='queryParams.author != null and queryParams.author.trim() neq \"\"'>"
            + " AND c.author like  CONCAT('%',#{queryParams.author},'%')"
            + "</if>"
            + "<if test='queryParams.realName != null and queryParams.realName.trim() neq \"\"'>"
            + " AND c.real_name like  CONCAT('%',#{queryParams.realName},'%')"
            + "</if>"
            + "</where>"
            +"</script>")
    Page<CoachComment> getAllCourseCommentPage(Page<CoachComment> page, @Param("queryParams") CoachCommentQueryParams queryParams);
}
